package org.example.collection.set;

import java.util.*;
import java.util.function.Consumer;

public class HashSetTest {
    public static void main(String[] args) {
//        test1();
        test2();
    }

    private static void test2() {
        HashSet<Integer> set = new HashSet<>(List.of(4, 2, 3, 1));
        for(Integer e : set)    // 1234
            System.out.print(e);
        System.out.println();
        Spliterator<Integer> spliterator = set.spliterator();
        spliterator.forEachRemaining(System.out::print);  // 1234
        System.out.println();

        LinkedHashSet<Integer> set1 = new LinkedHashSet<>(List.of(4, 2, 3, 1));
        for(Integer e : set1)   // 4231
            System.out.print(e);
        System.out.println();
        Spliterator<Integer> spliterator1 = set1.spliterator();
        spliterator1.forEachRemaining(System.out::print); // 4231
    }

    public static void test1() {
        String a = "asdasdqweqcsdvs";
        Integer c = 1231;
        System.out.println(a.hashCode());   // 1222787807
        System.out.println(c.hashCode());   // 1231
    }
}
